from django.db import models

# 班级主表
class Clazz(models.Model):
    cno = models.AutoField(primary_key=True)
    cname = models.CharField(max_length=100)

# 学生表（多）
class Student(models.Model):
    sno = models.AutoField(primary_key=True)
    sname = models.CharField(max_length=100)
    cno = models.ForeignKey(Clazz,on_delete=models.CASCADE,related_name='sts')

    def __str__(self):
        return u'Student:%s'%self.sname

# 课程
class Course(models.Model):
    course_no = models.AutoField(primary_key=True)
    course_name = models.CharField(max_length=100)

    def __str__(self):
        return u'Course:%s'%self.course_name

#   教师
class Teacher(models.Model):
    tno = models.AutoField(primary_key=True)
    tname = models.CharField(max_length=100)
    cour = models.ManyToManyField(Course)

    def __str__(self):
        return u'Teacher:%s'%self.tname
